﻿using System;
using Microsoft.Practices.ObjectBuilder;

namespace Microsoft.Practices.CompositeUI
{
    /// <summary>
    /// 	Base class for dependency attributes that can be made optional.
    /// </summary>
    public abstract class OptionalDependencyAttribute : ParameterAttribute
    {
        #region Fields & Properties

        private bool _required = true;

        /// <summary>
        /// 	Whether the dependency is required. Defaults to true.
        /// </summary>
        public bool Required
        {
            get
            {
                return _required;
            }
            set
            {
                _required = value;
            }
        }

        #endregion

        #region Overrides of ParameterAttribute

        /// <summary>
        /// 	See <see cref = "ParameterAttribute.CreateParameter" /> for more information.
        /// </summary>
        public override abstract IParameter CreateParameter(Type memberType);

        #endregion
    }
}